package org.yagnus.scalasupport.iterates

class IteratorJavaCollections[T](in : java.util.Collection[T]) extends Iterator[T] {
    val itr = in.iterator;
    def hasNext = (itr != null && itr.hasNext);
    def next = itr.next;
}
class IterableJavaCollections[T](in : java.util.Collection[T]) extends Iterable[T] {
    def iterator : Iterator[T] = return new IteratorJavaCollections(in);
}

object IterateJavaCollections {
    implicit def iterableOverJavaCollections[T](in : java.util.Collection[T]) : Iterable[T] = new IterableJavaCollections(in);
    implicit def iterateOverJavaCollections[T](in : java.util.Collection[T]) : Iterator[T] = new IteratorJavaCollections(in);
}